package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author linbinchen
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 重定向根路径到swagger-ui
        registry.addRedirectViewController("/", "/swagger-ui/");

        // 添加其他重定向
        registry.addRedirectViewController("/api", "/swagger-ui/");
        registry.addRedirectViewController("/docs", "/swagger-ui/");
    }
}